﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Collections.Specialized;
using System.Collections;
using System.Globalization;

using ECCIT;
using OgilvyOne.Sharan.Model;
using OgilvyOne.Sharan.IDAL;
using OgilvyOne.Sharan.DALFactory;

namespace OgilvyOne.Sharan.BLL
{
    public class WeiboImageReplacer
    {
        private const string C_IMAGE_URL = "http://www.sharan.com.cn/weibo/images/kol/{0}";

        private static readonly Hashtable ReplaceImages = GetReplacedImages();

        private static Hashtable GetReplacedImages()
        {
            Hashtable images = new Hashtable();
            images.Add("http://ww4.sinaimg.cn/large/6b6c950djw1dqwr9dbg78j.jpg", string.Format(C_IMAGE_URL, "ldd_20120312.jpg"));
            images.Add("http://ww4.sinaimg.cn/bmiddle/6b6c950djw1dqwr9dbg78j.jpg", string.Format(C_IMAGE_URL, "ldd_20120312.jpg"));
            images.Add("http://ww2.sinaimg.cn/large/405acef7jw1dqvjqvxbx3j.jpg", string.Format(C_IMAGE_URL, "yax_20120312.jpg"));
            images.Add("http://ww2.sinaimg.cn/bmiddle/405acef7jw1dqvjqvxbx3j.jpg", string.Format(C_IMAGE_URL, "yax_20120312.jpg"));

            return images;
        }

        public static string ReplaceImage(string originalImagePath)
        {
            if (originalImagePath == null) return null;

            if (ReplaceImages.Contains(originalImagePath))
                return ReplaceImages[originalImagePath].ToString();

            return originalImagePath;
        }
    }
}